package com.itheima.project.web;

import com.itheima.project.basic.ResponseWrap;
import com.itheima.project.core.enums.dict.PlacesEnum;
import com.itheima.project.face.PlacesFace;
import com.itheima.project.utils.ResponseWrapBuild;
import com.itheima.project.vo.dict.PlacesVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName PlacesController.java
 * @Description 地区controller
 */
@RestController
@RequestMapping("places")
@Api(tags = "地区controller")
public class PlacesController {

    @Autowired
    PlacesFace placesFace;

    /**
     * @Description 保存字典数据
     * @return
     */
    @GetMapping("{parentId}")
    @ApiOperation(value = "地区下拉框",notes = "地区下拉框")
    @ApiImplicitParam(name = "parentId",value = "父层id",required = true,dataType = "Long")
    public ResponseWrap<List<PlacesVo>> findPlacesVoListByParentId(@PathVariable("parentId") Long parentId) {
        List<PlacesVo> placesVos = placesFace.findPlacesVoListByParentId(parentId);
        return ResponseWrapBuild.build(PlacesEnum.SUCCEED,placesVos);
    }
}
